package com.hzy.fivepalace.admin.controller;

import com.hzy.fivepalace.admin.annotation.Login;
import com.hzy.fivepalace.admin.controller.base.BaseController;
import com.hzy.fivepalace.common.util.ResponseUtil;
import com.hzy.fivepalace.db.domain.DtsGoodsSecurity;
import com.hzy.fivepalace.db.domain.DtsNoDeliveryRegion;
import com.hzy.fivepalace.db.service.DtsGoodsSecurityService;
import com.hzy.fivepalace.db.service.DtsLogisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 商品服务
 *
 * @author gejian
 */
@RestController
@RequestMapping("/admin/logistics")
@Api(tags = "物流服务")
@ResponseBody
@Login
public class AdminLogisticsController extends BaseController {

    @Resource
    private DtsLogisticsService logisticsService;

    /**
     * 获取物流说明
     *
     * @return
     */
    @PostMapping("/getLogisticsInstructions")
    @ApiOperation(value = "获取物流说明")
    public Object getLogisticsInstructions() {


        return ResponseUtil.ok("查询成功", logisticsService.getLogisticsInstructions());
    }


    /**
     * 获取不发货地区
     *
     * @param name
     * @return
     */
    @PostMapping("/getNoDeliveryRegion")
    @ApiOperation(value = "获取不发货地区")
    public Object getNoDeliveryRegion(@ApiParam(value = "检索用:地区名称") @RequestParam(required = false, defaultValue = "", value = "name") String name) {


        return logisticsService.getNoDeliveryRegionListByThread(name);
    }

    /**
     * 删除不发货地区
     *
     * @param id
     * @return
     */
    @PostMapping("/delNoDeliveryRegion")
    @ApiOperation(value = "删除不发货地区")
    public Object delNoDeliveryRegion(@ApiParam(value = "主键") @RequestParam @NotNull Integer id) {


        return logisticsService.delNoDeliveryRegionListByThread(id);
    }

    @PostMapping("/addNoDeliveryRegion")
    @ApiOperation(value = "新增不发货地区")
    public Object addNoDeliveryRegion(DtsNoDeliveryRegion region) {


        return logisticsService.addNoDeliveryRegion(region,getAdminId());
    }

    /**
     * 修改物流说明
     *
     * @param content
     * @return
     */
    @PostMapping("/updLogisticsInstructions")
    @ApiOperation(value = "修改物流说明")
    public Object updLogisticsInstructions(@ApiParam(value = "内容") @RequestParam @NotBlank String content) {

        return logisticsService.updLogisticsInstructions(content);
    }

}
